﻿/*
* 此类由ConfigTools自动生成. https://github.com/huangkumao/ConfigTools
*/
using System;
using System.Collections.Generic;
using UnityEngine;

namespace Configs
{
    [Serializable]
    public class ConfUnitObjectData
    {
        public List<ConfUnitObject> mDataList;
    }

    [Serializable]
    public class ConfUnitObject
    {
        /* ID唯一，必须有 */
        public int id;
        /* 名称 */
        public string name;
        /* 类型: 1=MonsterObject; 2=TowerObject; */
        public int type;
        /* 攻击 */
        public int att;
        /* 防御 */
        public int def;
        /* 模型 */
        public string model;


        /*
        * 静态成员数据
        */
        private static Dictionary<int, ConfUnitObject> mDataMap = new Dictionary<int, ConfUnitObject>();

        public static void Reload()
        {
            string strJson = Resources.Load<TextAsset>("Json/ConfUnitObject").text;
            ConfUnitObjectData datas = JsonUtility.FromJson<ConfUnitObjectData>(strJson);

            mDataMap.Clear();

            foreach (ConfUnitObject conf in datas.mDataList)
            {
                mDataMap.Add(conf.id, conf);
            }
        }

        public static ConfUnitObject Get(int id)
        {
            if (mDataMap.ContainsKey(id))
                return mDataMap[id];
            return null;
        }

    }
}
